package com.ypinkj.app.api;


import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.ypinkj.app.entity.CollectPositionVo;
import com.ypinkj.app.entity.UCollect;
import com.ypinkj.app.mapper.UCollectMapper;
import com.ypinkj.app.utils.resultutils.Result;
import com.ypinkj.app.utils.resultutils.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author LF
 * @since 2020-09-29
 */
@Api(tags = "收藏管理")
@RestController
@RequestMapping("/u-collect")
public class UCollectController {

    @Autowired
    UCollectMapper collectMapper;

    @ApiOperation(value = "新增收藏")
    @PutMapping
    public Result save(@RequestBody UCollect collect){
        return collectMapper.insert(collect)>0 ? ResultUtil.success() : ResultUtil.errorMsg();
    }

    @ApiOperation(value = "收藏职位列表")
    @GetMapping
    public Result getList(String userid){
        List<CollectPositionVo> list = collectMapper.getCollectPositionList(userid);
        return list.size()>0 ? ResultUtil.success(list) : ResultUtil.error("暂无数据");
    }

}
